import Vue from "vue"
import msgBox from "./index.vue"
import Promise from "bluebird"
const msgConstructor =  Vue.extend(msgBox)
var instance

export default {
  open (config) {
    return new Promise (function (resolve) {
      if (!instance) {
        instance = new msgConstructor({
          el:document.createElement("div")
        })
        instance.$el.id = "msgBox-container"
        document.body.appendChild(instance.$el)
      } else {
        instance.msgBoxShow = true
      }
      instance.title = config ?config.title : ""   
      instance.callBack = resolve
    }) 
  }
}